package com.xiyu.service.controller.admin.market;
import com.xiyu.service.vo.market.marketTemplate.MarketTemplateGetResourceByTemplateIdOutput;
import com.xiyu.service.vo.market.marketTemplate.MarketTemplateGetContentByTemplateIdOutput;
import com.xiyu.service.vo.market.marketTemplate.MarketTemplateSimpleListOutput;
import com.xiyu.service.vo.market.marketTemplate.MarketTemplateSingleGetOutput;
import com.xiyu.service.vo.market.marketTemplate.MarketTemplatePageQueryOutput;
import com.xiyu.service.vo.market.marketTemplate.MarketTemplatePageQueryInput;
import com.xiyu.service.vo.market.marketTemplate.MarketTemplateUpdateInput;
import com.xiyu.service.vo.market.marketTemplate.MarketTemplateCreateInput;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import jakarta.validation.*;

import java.util.*;

import com.xiyu.service.framework.web.web.core.pojo.PageResult;
import com.xiyu.service.framework.web.web.core.pojo.CommonResult;
import static com.xiyu.service.framework.web.web.core.pojo.CommonResult.success;

import com.xiyu.service.framework.excel.core.util.ExcelUtils;

import com.xiyu.service.framework.operateLog.core.annotations.OperateLog;
import static com.xiyu.service.framework.operateLog.core.enums.OperateTypeEnum.*;

import com.xiyu.service.service.market.MarketTemplateService;

@Tag(name = "营销模板")
@RestController
@RequestMapping("/market/market-template")
@Validated
public class MarketTemplateController {

    @Resource
    private MarketTemplateService marketTemplateService;

    @PostMapping("/create")
    @Operation(summary = "新增营销模板")
    public CommonResult<Long> create(@Valid @RequestBody MarketTemplateCreateInput inputVO) {
        return success(marketTemplateService.create(inputVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新营销模板")
    public CommonResult<Boolean> update(@Valid @RequestBody MarketTemplateUpdateInput inputVO) {
        return success(marketTemplateService.update(inputVO));
    }

    @DeleteMapping("/deleted")
    @Operation(summary = "删除营销模板")
    @Parameter(name = "id", description = "营销模板主键ID", example = "")
    public CommonResult<Boolean> deleted(@RequestParam("id") Long id) {
        return success(marketTemplateService.deleted(id));
    }

    @GetMapping("/page-query")
    @Operation(summary = "分页查询营销模板")
    public CommonResult<PageResult<MarketTemplatePageQueryOutput>> pageQuery(@Valid MarketTemplatePageQueryInput inputVO) {
        return success(marketTemplateService.pageQuery(inputVO));
    }

    @GetMapping("/single-get")
    @Operation(summary = "获取单个营销模板")
    @Parameter(name = "id", description = "营销模板主键ID", example = "")
    public CommonResult<MarketTemplateSingleGetOutput> singleGet(@RequestParam("id") Long id) {
        return success(marketTemplateService.singleGet(id));
    }

    @GetMapping("/simple-list")
    @Operation(summary = "查询营销模板")
    public CommonResult<List<MarketTemplateSimpleListOutput>> simpleList() {
        return success(marketTemplateService.simpleList());
    }

    @GetMapping("/get-content-by-template-id")
    @Operation(summary = "根据TemplateId获取正文")
    @Parameter(name = "templateId", description = "模板ID", example = "")
    public CommonResult<MarketTemplateGetContentByTemplateIdOutput> getContentByTemplateId(@RequestParam("templateId") Long templateId) {
        return success(marketTemplateService.getContentByTemplateId(templateId));
    }

    @GetMapping("/get-resource-by-template-id")
    @Operation(summary = "根据TemplateId获取资源")
    @Parameter(name = "templateId", description = "模板ID", example = "")
    public CommonResult<List<MarketTemplateGetResourceByTemplateIdOutput>> getResourceByTemplateId(@RequestParam("templateId") Long templateId) {
        return success(marketTemplateService.getResourceByTemplateId(templateId));
    }

}
